package com.hzhr.iot.meterplan.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.dto.ResponseExceptionDto;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.meterplan.controller.base.BaseController;
import com.hzhr.iot.meterplan.model.meterGasUser.MeterGasUserGetModel;
import com.hzhr.iot.meterplan.model.meterPlan_workOrder.MeterPlan_workOrderGetModel;
import com.hzhr.iot.meterplan.model.meterPlan_workOrder.MeterPlan_workOrderModel;
import com.hzhr.iot.meterplan.service.MeterGasUserService;
import com.hzhr.iot.meterplan.service.MeterPlan_WorkOrderService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "MeterGasUser", description = "抄表用户")
@RestController
@RequestMapping(value = "")
public class MeterGasUserController extends BaseController {
    @Autowired
    MeterGasUserService meterGasUserService;

    //region /meter-plans GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="简介：查询登录用户管辖范围内的抄表用户", notes="简介：查询登录用户管辖范围内的抄表用户  \n步骤：  \n1.查询登录用户管辖范围内的并且状态为“在用”燃气用户  \n注意以下查询规则：  \n(1) 在query参数notequal_meterPlanId不为空，如果查询出的燃气用户在某个抄表计划下，那么这个抄表计划的状态不应该是“执行中”  \n2.返回信息；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "equal_meterPlanId", value = "筛选条件：where MeterGasUserModel.meterPlanId = #{equal_meterPlanId}", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "notequal_meterPlanId", value = "筛选条件：where MeterGasUserModel.meterPlanId != #{equal_meterPlanId}", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "like_code", value = "筛选条件：where MeterGasUserModel.code like #{like_code} + %", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "like_name", value = "筛选条件：where MeterGasUserModel.name like  #{like_name} + %", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "like_address", value = "筛选条件：where MeterGasUserModel.address like #{like_address} + %", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_typeId", value = "筛选条件：where MeterGasUserModel.typeId != #{equal_typeId}", required = false, dataType = "string", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_equal_meterPlanId", value = "筛选条件：where MeterGasUserModel.meterPlanId = #{_equal_meterPlanId}", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_notequal_meterPlanId", value = "筛选条件：where MeterGasUserModel.meterPlanId != #{_equal_meterPlanId}", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_like_code", value = "筛选条件：where MeterGasUserModel.code like #{_like_code} + %", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_like_name", value = "筛选条件：where MeterGasUserModel.name like  #{_like_name} + %", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_like_address", value = "筛选条件：where MeterGasUserModel.address like #{_like_address} + %", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_typeId", value = "筛选条件：where MeterGasUserModel.typeId != #{_equal_typeId}", required = false, dataType = "string", paramType = "query"),
    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/meter-gas-users", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<MeterGasUserGetModel> get(@RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        MeterGasUserGetModel responseBody = meterGasUserService.get(initHeader(),query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
    }
    //endregion
}




